import os

from django.conf.urls.defaults import *

from leonardo.cms.views import display_content, blog
from leonardo.cms.feeds import FullFeed


urlpatterns = patterns('',
    (r'^admin/', include('django.contrib.admin.urls')),
    
    (r'^(\d{4}/.*)$', 'django.views.static.serve',
        {'document_root': os.path.join(os.path.dirname(__file__), "cms/STATIC")}),
    
    (r'^(favicon.ico)$', 'django.views.static.serve',
        {'document_root': os.path.join(os.path.dirname(__file__), "cms/STATIC")}),
    
    (r'^static/(.*)$', 'django.views.static.serve',
        {'document_root': os.path.join(os.path.dirname(__file__), "static")}),
    
    
    (r'^$', display_content, {"path": "__home__"}),
    
    (r"^atom/(.*)/$", "django.contrib.syndication.views.feed", {
        "feed_dict": {
            "full": FullFeed,
        }
    }),
    
    (r"^atom03", "django.views.generic.simple.redirect_to", {'url': "/atom/full/"}),
    (r"^atom10", "django.views.generic.simple.redirect_to", {'url': "/atom/full/"}),
    (r"^atom/$", "django.views.generic.simple.redirect_to", {'url': "/atom/full/"}),
    
    (r'^blog/$', blog),
    (r'^blog/(\d{4})/$', blog),
    (r'^blog/(\d{4})/(\d{2})/$', blog),
    (r'^blog/(\d{4})/(\d{2})/(\d{2})/$', blog),
    (r'^blog/(\d{4})/(\d{2})/(\d{2})/(.+)/$', blog),
    
    (r'^(.*)/$', display_content),
)
